const {queryMysql}=require('../utils/queryMysqlUtil')
exports.getAllGroupList=async function(){
  const queryStr=`select * from chihiro_team_group`
  let { results }=await queryMysql(queryStr).catch((err)=>{
    console.log(err)
    return Promise.reject(err)
  })
  return Promise.resolve(results)
}
exports.getAllBranchList=async function(){
    const queryStr=`select * from chihiro_branch`
    let { results }=await queryMysql(queryStr).catch((err)=>{
        console.log(err)
        return Promise.reject(err)
    })
    return Promise.resolve(results)
}

exports.getGroupListByBranchId=async function(branchId){
    const queryStr=`select chihiro_branch.id as branchId,chihiro_team_group.id as groupId,group_name, chihiro_team_group.create_time, chihiro_team_group.update_time from chihiro_branch left join chihiro_team_group on chihiro_branch.id=chihiro_team_group.branch_id where chihiro_branch.id=${branchId}`
    let { results }=await queryMysql(queryStr).catch((err)=>{
        console.log(err)
        return Promise.reject(err)
    })
    return Promise.resolve(results)
}
